package com.gsafety.wellsfort.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.gsafety.wellsfort.common.enums.CustomerTypeEnum;
import com.gsafety.wellsfort.domain.model.knowledge.Courseware;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.Date;
import java.util.List;

@Data
@ApiModel(value = "课件")
public class CoursewareVO {
    @ApiModelProperty(value = "课件id")
    private Integer id;

    @ApiModelProperty(value = "课件对象值")
    private Integer objectType;
    @ApiModelProperty(value = "课件对象文本")
    private String objectTypeText;

    @ApiModelProperty(value = "课件文件URL")
    private String fileUrl;

    @ApiModelProperty(value = "标题")
    private String title;

    @ApiModelProperty(value = "关键字")
    private String keyword;

    @ApiModelProperty(value = "建议学习时长")
    private Integer learningTime;

    @ApiModelProperty(value = "启用状态:0禁用1启用")
    private Byte isOpen;


    private Integer creator;
    @ApiModelProperty(value = "添加人名字")
    private String creatorName;


    @ApiModelProperty(value = "添加时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;


    private Integer modified;
    @ApiModelProperty(value = "修改人字")
    private String modifiedName;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "权限列表")
    List<CoursewarePrivilegeVO> privilegeList;

    public static  class VOBuilder{
        Courseware courseware;
        CoursewareVO coursewareVO =new CoursewareVO();
        public VOBuilder(Courseware q){
            this.courseware =q;
        }
        public CoursewareVO build(){
            BeanUtils.copyProperties(courseware, coursewareVO);
            coursewareVO.setObjectTypeText(CustomerTypeEnum.parseVal(coursewareVO.getObjectType()).label);
            return coursewareVO;
        }
    }
}
